package main

import (
	"server_cluster/common/logger"
	"server_cluster/logic/game_config"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	gorm_logger "gorm.io/gorm/logger"
)

func main() {
	game_config.InitConfig()
	logger.InitLogger("game_data_config", "debug")
	defer logger.CloseLogger()

	var gormLogger gorm_logger.Interface = nil
	if game_config.GetConfig().LogSql {
		gormLogger = gorm_logger.Default.LogMode(gorm_logger.Info)
	}
	gormDb, err := gorm.Open(mysql.Open(game_config.GetConfig().GetDbHost()), &gorm.Config{
		Logger: gormLogger,
	})
	if err != nil {
		panic(err)
	}

	game_config.LoadConfigTable(gormDb)
}
